package com.zhkj.txg.module.find.adapter

import android.content.Context
import android.view.ViewGroup
import android.widget.ImageView
import com.zhkj.txg.module.home.adapter.BannerViewHolder
import com.zhkj.txg.utils.ImageUtils
import com.youth.banner.adapter.BannerAdapter

class FindBannerAdapter(
    private val context: Context
) : BannerAdapter<String, BannerViewHolder>(null) {
    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): BannerViewHolder {
        val imageView = ImageView(context).apply {
            layoutParams =
                ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
        }
        return BannerViewHolder(imageView)
    }

    override fun onBindView(holder: BannerViewHolder?, data: String?, position: Int, size: Int) {
        if (holder != null && data != null) {
            holder.let { ImageUtils.loadImage(context, it.img, data) }
        }
    }
}